package com.jzj.jzjctripapi.utils;

import org.springframework.beans.BeanUtils;

/**
 * @author Mazhenming
 * @date 2023/11/10 10:37
 * @desciption: EntityConverter 实体覆盖到第三方jar包中实体
 */
public class EntityConverterUtil {
    public static <T, U> T convert(U source, Class<T> targetClass) {
        T target = null;
        try {
            target = targetClass.newInstance();
            BeanUtils.copyProperties(source, target);
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return target;
    }
}
